//
//  InputController.swift
//  LiteAccount
//
//  Created by 刘伟 on 2017/6/3.
//  Copyright © 2017年 刘伟. All rights reserved.
//

import UIKit

class InputController: UIViewController {

    @IBOutlet weak var contentView: UIView!
    
    var titleText: String! {
        didSet {
            titleLabel.text = titleText
        }
    }
    
    var detailText: String! {
        didSet {
            detailLabel.text = detailText
        }
    }
    
    var content: String! {
        get {
            return inputTextField.text
        }
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        prepareUI()
        layoutUI()
    }
    
    fileprivate func prepareUI() {
        inputTextField.becomeFirstResponder()
        self.contentView.addSubview(titleLabel)
        self.contentView.addSubview(inputTextField)
        self.contentView.addSubview(detailLabel)
    }
    
    fileprivate func layoutUI() {
        titleLabel.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.top.left.equalTo(10)
            make.height.equalTo(20)
        }
        inputTextField.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.top.equalTo(titleLabel.snp.bottom).offset(10)
            make.left.equalTo(10)
            make.bottom.equalTo(-25)
        }
        detailLabel.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.top.equalTo(inputTextField.snp.bottom).offset(8)
            make.left.equalTo(10)
        }
    }
    
    
    // MARK: 组件
    
    lazy var titleLabel: UILabel = {
        let object = UILabel()
        object.textColor = .black
        object.font = UIFont.la_Font(ofSize: 15)
        object.textAlignment = .center
        object.text = ""
        return object
    }()
    
    
    fileprivate lazy var inputTextField: UITextView = {
        let object = UITextView()
        object.layer.borderWidth = 0.5
        object.layer.cornerRadius = 2
        object.layer.borderColor = UIColor.la_grayer.cgColor
        object.font = UIFont.la_Font(ofSize: 14)
        return object
    }()
    
    fileprivate lazy var detailLabel: UILabel = {
        let object = UILabel()
        object.textColor = .la_gray
        object.font = UIFont.la_Font(ofSize: 12)
        object.textAlignment = .center
        object.text = ""
        return object
    }()

    

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}
